<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script type="text/javascript">
        function onsubmitFun() {
            alert("静态注册表单实现---表单不合法")

            return false;
        }

        window.onload = function() {
            var test = document.getElementById("sel1");
            test.onsubmit = function() {
                alert("动态注册表单实现--表单不合法")
                // return false;
            }
        }
    </script>
</head>
<body>
    <!-- return false可以阻止表单提交 -->
    <form action="https://www.baidu.com" method="get" onsubmit="return onsubmitFun();">
        <input type="submit" value="静态注册"/>
    </form>

    <form action="https://www.baidu.com" id="sel1">
        <input type="submit" value="动态注册"/>
    </form>
    
</body>
</html>